package net.dodoman.jdbc;

import java.sql.*;

public class Dbaccess {

	public static void main(String args[]) throws Exception {
		Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
		String dburl = "jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ=Mobile.mdb";// 此为NO-DSN方式
		// String dburl ="jdbc:odbc:odbcName";//此为ODBC连接方式
		Connection conn = DriverManager.getConnection(dburl);
		Statement stmt = conn.createStatement();
		ResultSet rs = stmt.executeQuery("select Top 20 * from MobileSection");
		System.out.println("号段\t地区\t类型\t省份\t区号");
		while (rs.next()) {
			System.out.println(rs.getString(1) + "\t" + rs.getString(2) + "\t"
					+ rs.getString(3) + "\t" + rs.getString(4) + "\t"
					+ rs.getString(5));
		}
	}
}